import yfinance as yf
import pandas as pd
from datetime import date, timedelta
import plotly.express as px
import plotly.graph_objects as go
today = date.today()
today
datetime.date(2022, 10, 26)
end = today.strftime('%Y-%m-%d')
start = (today-timedelta(days=720)).strftime('%Y-%m-%d')
print(start, end)
2020-11-05 2022-10-26
amd = yf.download('AMD',start=start, end=end)
[*********************100%***********************] 1 of 1 completed
#amd = amd.reset_index()
amd.head()
| Open | High | Low | Close | Adj Close | Volume | |
|---|---|---|---|---|---|---|
| Date | ||||||
| 2020-11-05 00:00:00-05:00 | 83.269997 | 83.500000 | 81.849998 | 83.000000 | 83.000000 | 46542300 |
| 2020-11-06 00:00:00-05:00 | 83.519997 | 86.089996 | 82.669998 | 85.879997 | 85.879997 | 53829900 |
| 2020-11-09 00:00:00-05:00 | 84.239998 | 87.050003 | 82.769997 | 83.120003 | 83.120003 | 58580700 |
| 2020-11-10 00:00:00-05:00 | 81.930000 | 82.129997 | 77.629997 | 77.989998 | 77.989998 | 67137200 |
| 2020-11-11 00:00:00-05:00 | 79.389999 | 81.470001 | 78.970001 | 81.279999 | 81.279999 | 44611300 |
fig = go.Figure(
data=[
go.Scatter(
x=amd.index,
y=amd.Close
)
]
)
fig.show()
fig=px.line(amd, x=amd.index, y='Close',title='AMD Stock Close Price - Line Chart')
fig.show()
fig = go.Figure(
data = [
go.Candlestick(
x=amd.index,
open=amd['Open'],
high=amd['High'],
low=amd['Low'],
close=amd['Close']
)
]
)
fig.update_layout(title='AMD Stock Close Price - Candle Stick', template='seaborn')
fig.show()
fig = go.Figure(
data=[
go.Bar(
x=amd.index,
y=amd['Close']
)
]
)
fig.layout.template='seaborn'
fig.update_layout(margin=dict(t=40,b=5,l=5,r=20),title='AMD Stock Close Price - Line Chart')
fig.show()
By looking at the charts above which show stock prices in the past two years, AMD had strong performance in 2021 but stock price started to plunge at the end of the year and the trend lasts. The increase of stock price in 2021 is mostly attributable to overall strong economy and company's well performance.
In 2009, AMD spun off it's semiconductor factory, GLOBALFOUNDRIES Inc. Since then, it has the flexibility to select manufacturers. In addition, when it comes to designing CPU, AMD managed to provide chips with smaller node size( 6-nanometer scale) and beat Intel.
AMD's EPS has beated the market expectation more than four consecutive quarters, resulting from it's strong performance. However, since 2022, AMD faced some obatacles - supply chain issues and lower global sales of personal computers that puts demand of semiconductor in question, causing the stock price to plunge.
Competitors: Intel (INTC) / Nvidia (NVDA) / Qualcomm (QCOM) / Analog Devices (ADI) / Synaptics (SYNA)
intc = yf.download('INTC', start=start, end=end)
nvda = yf.download('NVDA', start=start, end=end)
qcom = yf.download('QCOM', start=start, end=end)
[*********************100%***********************] 1 of 1 completed [*********************100%***********************] 1 of 1 completed [*********************100%***********************] 1 of 1 completed
#px.line(intc, x=intc.index, y='Close',title = 'INTC Stock Close Price - Line Chart',template='seaborn')
#px.line(nvda, x=nvda.index, y='Close',title = 'NVDA Stock Close Price - Line Chart',template='seaborn')
#px.line(qcom, x=qcom.index, y='Close',title = 'QCOM Stock Close Price - Line Chart',template='seaborn')
#px.line(adi, x=adi.index, y='Close',title = 'ADI Stock Close Price - Line Chart',template='seaborn')
fig = go.Figure()
fig.add_trace(
go.Scatter(
name='INTC',
x=intc.index,
y=intc.Close
)
)
fig.add_trace(
go.Scatter(
name = 'NVDA',
x=nvda.index,
y=nvda.Close
)
)
fig.add_trace(
go.Scatter(
name = 'QCOM',
x=qcom.index,
y=qcom.Close
)
)
fig.add_trace(
go.Scatter(
name = 'AMD',
x=amd.index,
y=amd.Close
)
)
fig.update_layout(template='seaborn',title='Stock Price Comparison Chart - AMD vs Competitors',margin=dict(t=50,b=10))
fig.show()
Here I select three other competitors and compare to AMD by looking at their stock performance in the past two years.\ We can see that AMD, Nvidia, and Qualcomm are having the same pattern of fluctuation - increased stock price in 2021 and decreased in 2022. This is partly attributable to global economy and partly to semiconductor industry development and the issues that this industy is facing. However, Intel seemed weak and the trend keeps going down gradually since April 2021. To analyze which stock is a better choice for investors, we'll need to look into the financial statements, company statistics, and other information.